﻿using Microsoft.AspNetCore.Mvc;
using mozhi.smarterp.AuthorCenter.Departments;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Volo.Abp;

namespace mozhi.smarterp.AuthorCenter.Controllers
{
    [RemoteService]
    [Route("api/identity/departments")]
    public class DepartmentController : AuthorCenterController
    {
        private IDepartmentAppService _appService;

        public DepartmentController(IDepartmentAppService appService)
        {
            _appService = appService;
        }

        [HttpGet]
        [Route("{id}")]
        public async Task<DepartmentDto> GetAsync(Guid id)
        {
            return await _appService.GetAsync(id);
        }

        [HttpGet]
        public async Task<List<DepartmentDto>> GetListAsync(DepartmentFilter filter)
        {
            return await _appService.GetListAsync(filter);
        }

        [HttpPost]
        public async Task<DepartmentDto> CreateAsync(DepartmentCreateDto input)
        {
            return await _appService.CreateAsync(input);
        }

        [HttpPut]
        public async Task<DepartmentDto> UpdateAsync(DepartmentUpdateDto input)
        {
            return await _appService.UpdateAsync(input);
        }

        [HttpDelete]
        [Route("{id}")]
        public async Task DeleteAsync(Guid id)
        {
            await _appService.DeleteAsync(id);
        }
    }
}
